﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ucEditUser.ascx.cs" Inherits="WebForm_ManageUser_ucEditUser" %>
<div align="center">
    <asp:Label ID="lblTitle" runat="server" Text="<%$ Resources:TitleAdd %>" SkinID="title"></asp:Label>
</div>
<My:MyFormView ID="FormView1" runat="server" DataSourceID="ObjectDataSource1" Width="100%"
    OnItemInserting="FormView1_ItemInserting" OnItemUpdating="FormView1_ItemUpdating">
    <ItemTemplate>
        <table border="1" bordercolor="#f0f0f0" cellpadding="0" cellspacing="0" width="100%">
            <tr>
                <td class="td_header">
                    <asp:Label ID="lblEmployeeID" runat="server" Text="<%$ Resources:EmployeeID %>"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="txtEmployeeID" runat="server" MaxLength="50" Text='<%# Bind("EmployeeID") %>'></asp:TextBox>
                    <asp:RequiredFieldValidator ID="chk_txtEmployeeID" runat="server" ControlToValidate="txtEmployeeID"
                        Display="None" ErrorMessage="<%$ Resources:chk_txtEmployeeID %>" ValidationGroup="Save"></asp:RequiredFieldValidator>
                </td>
                <td class="td_header">
                    <asp:Label ID="lblEmployeeName" runat="server" Text="<%$ Resources:EmployeeName %>"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="txtEmployeeName" runat="server" MaxLength="50" Text='<%# Bind("EmployeeName") %>'></asp:TextBox>
                    <asp:RequiredFieldValidator ID="chk_txtEmployeeName" runat="server" ControlToValidate="txtEmployeeName"
                        Display="None" ErrorMessage="<%$ Resources:chk_txtEmployeeName %>" ValidationGroup="Save"></asp:RequiredFieldValidator>
                </td>
                <td class="td_header">
                    <asp:Label ID="lblOrganizationID" runat="server" Text="<%$ Resources:OrganizationName %>"></asp:Label>
                </td>
                <td>
                    <asp:DropDownList ID="ddlOrganizationID" runat="server" DataSourceID="ObjectDataSource_Organization"
                        DataTextField="OrganizationName" DataValueField="OrganizationID" OnDataBound="ddlOrganizationID_DataBound"
                        OnDataBinding="ddlOrganizationID_DataBinding" SelectedValue='<%# Bind("OrganizationID") %>'>
                    </asp:DropDownList>
                    <asp:RequiredFieldValidator ID="chk_ddlOrganizationID" runat="server" ControlToValidate="ddlOrganizationID"
                        Display="None" ErrorMessage="<%$ Resources:chk_ddlOrganizationID %>" InitialValue="0"
                        ValidationGroup="Save"></asp:RequiredFieldValidator>
                    <asp:ObjectDataSource ID="ObjectDataSource_Organization" runat="server" OldValuesParameterFormatString="original_{0}"
                        SelectMethod="BLL_SelectMyOrganization" TypeName="BLL_ManageUser">
                        <SelectParameters>
                            <asp:Parameter Name="MyOrganizationID" Type="Int32" />
                        </SelectParameters>
                    </asp:ObjectDataSource>
                </td>
            </tr>
            <tr>
                <td class="td_header">
                    <asp:Label ID="lblPassword" runat="server" Text="<%$ Resources:Password %>"></asp:Label>
                    <asp:CompareValidator ID="chk_txtPassword" runat="server" ControlToCompare="txtPasswordConfirm"
                        ControlToValidate="txtPassword" Display="None" ErrorMessage="<%$ Resources:chk_txtPassword %>"
                        ValidationGroup="Save"></asp:CompareValidator>
                    <%--                    <asp:RequiredFieldValidator ID="chk_txtPassword2" runat="server" 
                        ControlToValidate="txtPassword" Display="None" 
                        ErrorMessage="<%$ Resources:chk_txtPassword2 %>" ValidationGroup="Save"></asp:RequiredFieldValidator>--%>
                </td>
                <td>
                    <asp:TextBox ID="txtPassword" runat="server" MaxLength="50" Text='<%# Bind("Password") %>'
                        TextMode="Password"></asp:TextBox>
                </td>
                <td class="td_header">
                    <asp:Label ID="lblPasswordConfirm" runat="server" Text="<%$ Resources:PasswordConfirm %>"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="txtPasswordConfirm" runat="server" MaxLength="50" TextMode="Password"></asp:TextBox>
                </td>
                <td class="td_header">
                    <asp:Label ID="lblActive" runat="server" Text="<%$ Resources:Active %>"></asp:Label>
                </td>
                <td>
                    <asp:CheckBox ID="chkActive" runat="server" Checked='<%# BooleanConverter(Eval("Active")) %>' />
                </td>
            </tr>
        </table>
        <My:MyGridView ID="gvProperty" runat="server" SkinID="pager" DataSourceID="odsProperty"
            meta:resourcekey="gvProperty" DataNames="PropertyName">
            <Columns>
                <asp:BoundField DataField="PropertyNameText" meta:resourcekey="bfPropertyName" />
                <asp:TemplateField meta:resourcekey="bfPropertyValue">
                    <itemtemplate>
                        <asp:TextBox id="txtPropertyValue" runat="server" Text='<%# Bind("PropertyValue") %>'></asp:TextBox>
                    </itemtemplate>
                </asp:TemplateField>
            </Columns>
        </My:MyGridView>
        <My:TableDataSource ID="odsProperty" runat="server" OnPreSelecting="odsProperty_OnPreSelecting" >
            <SelectQuery>
                <MyTable TableName="GetCodeMappingData('EmployeeProperty','PropertyName')" AliasName="cm" />
                <MyColumns>
                    <My:MyColumn ColumnList="PropertyName = cm.Value" />
                    <My:MyColumn ColumnList="PropertyNameText = cm.Text" />
                    <My:MyColumn ColumnList="ep.PropertyValue" />
                </MyColumns>
                <Relations>
                    <My:LeftJoin TableName="FD_EmployeeProperty" AliasName="ep" LeftKey="cm.Value"
                        RightKey="ep.PropertyName" >
                        <Conditions>
                            <My:VariableCondition ColumnName="ep.EmployeeID" VariableName="EmployeeID" />
                        </Conditions>
                    </My:LeftJoin>
                </Relations>
            </SelectQuery>
            <SelectParameters>
                <asp:Parameter Name="EmployeeID" />
            </SelectParameters>
        </My:TableDataSource>
        <%--        <asp:GridView>
            <Columns>
                <asp:BoundField
            </Columns>
        </asp:GridView>--%>
    </ItemTemplate>
</My:MyFormView>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" InsertMethod="BLL_Insert"
    OldValuesParameterFormatString="original_{0}" SelectMethod="BLL_Select" TypeName="BLL_ManageUser"
    UpdateMethod="BLL_Update">
    <UpdateParameters>
        <asp:Parameter Name="EmployeeID" Type="String" />
        <asp:Parameter Name="EmployeeName" Type="String" />
        <asp:Parameter Name="Password" Type="String" />
        <asp:Parameter Name="OrganizationID" Type="String" />
        <asp:Parameter Name="Active" Type="String" />
    </UpdateParameters>
    <SelectParameters>
        <asp:Parameter Name="EmployeeID" Type="String" />
        <asp:Parameter Name="EmployeeName" Type="String" />
        <asp:Parameter Name="OrganizationID" Type="String" />
        <asp:Parameter Name="MyOrganizationID" Type="Int32" />
    </SelectParameters>
    <InsertParameters>
        <asp:Parameter Name="EmployeeID" Type="String" />
        <asp:Parameter Name="EmployeeName" Type="String" />
        <asp:Parameter Name="Password" Type="String" />
        <asp:Parameter Name="OrganizationID" Type="String" />
        <asp:Parameter Name="Active" Type="String" />
    </InsertParameters>
</asp:ObjectDataSource>
<div align="center">
    <asp:ImageButton ID="btnSave" ImageUrl="~/images/image/but_21.jpg" CommandName="btnSave" ValidationGroup="Save" OnClick="btnSave_Click" runat="server" />
    <asp:ValidationSummary ID="Sum_Save" runat="server" DisplayMode="List" ShowMessageBox="True"
        ShowSummary="False" ValidationGroup="Save" />
</div>
